/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package seso;

import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import java.awt.geom.RoundRectangle2D;
import java.awt.Image;

/**
 *
 * @author Administrator
 */

public class RComboBoxButton extends javax.swing.JLabel { 

    Image imageNormal, imageRover;    
    private boolean  mouse_Entered = true;
    private final int arcWH = 8;

    
    public RComboBoxButton() {
        super();
        initControl();
    }
    
    private void initControl()  {
        setOpaque(false);  // Must be false
        setBorder(null);

        imageNormal = Util.getUserImage("resources/ComboBoxNormal.png");
        imageRover  = Util.getUserImage("resources/ComboBoxRover.png");
        
        addListener();        
    }
    

    private void addListener()    {

        addMouseListener(new java.awt.event.MouseAdapter() {

            public void mouseEntered(java.awt.event.MouseEvent evt) {
                mouse_Entered = true;
                repaint();
            }

            public void mouseExited(java.awt.event.MouseEvent evt) {
                mouse_Entered = false;
                repaint();
            }
        });
    
    }
    

    public void doRePaint(boolean mouse_Entered) {
        this.mouse_Entered = mouse_Entered;
        repaint();
    }



    @Override
    protected void paintComponent(Graphics g) {
        
        setText("");
        
        Graphics2D g2d = (Graphics2D) g;
        int height = getHeight();
        int width = getWidth();

        g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
        RoundRectangle2D.Double rect = new RoundRectangle2D.Double(0, 0, width, height, arcWH, arcWH);
        g2d.clip(rect);
        
        g.drawImage((mouse_Entered) ? imageRover : imageNormal, width - height, 0, height, height, null);
        super.paintComponent(g);
    }


}
